/**
 * jims
 */
package com.jims.master.modules.api.finance.web;


import com.jims.master.common.utils.DateUtil;
import com.jims.master.common.utils.StringUtils;
import com.jims.master.common.web.BaseController;
import com.jims.master.common.web.impl.BaseDto;
import com.jims.master.modules.finance.service.InpBillDetailService;
import com.jims.master.modules.finance.service.OutpBillItemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 价表相关rest
 * @author zhangyao
 */
@RestController
@RequestMapping(value = "his/api/finance")
public class FinanceRest extends BaseController {

    @Autowired
    private OutpBillItemsService outpBillItemsService;
    @Autowired
    private InpBillDetailService inpBillDetailService;

    /**
     * 获取收费数据
     * @param orgId 机构id
     * @param startDate 开始时间
     * @param endDate 结束时间
     * @param flag 门诊住院标识（0门诊1住院）
     * @return
     */
    @RequestMapping(value = "getCostList")
    public List<BaseDto> getCostList(@RequestParam String orgId,@RequestParam Date startDate,@RequestParam Date endDate,@RequestParam String flag){
        List<BaseDto> dtoList=new ArrayList<BaseDto>();
        //orgId month flag 不能为空
        if(StringUtils.isBlank(orgId)){
            return dtoList;
        }
        if(startDate==null || endDate==null){
            return dtoList;
        }
        if("0".equals(flag)){
            dtoList=outpBillItemsService.queryMonthList(orgId,startDate,endDate);
        }
        if("1".equals(flag)){
            dtoList=inpBillDetailService.queryMonthList(orgId,startDate,endDate);
        }
        return dtoList;
    }



}